package cate.game.db.facade;

import cate.game.db.mongo.rank.RankDao;
import cate.game.db.mongo.rank.RankMongo;

import java.util.Optional;

public class RankDaoFacade {
    private final RankDao dao;

    public RankDaoFacade(RankDao dao){
        this.dao = dao;
    }

    public void save(RankMongo kv){
        try{
            dao.save(kv);
        }catch(Exception e){
            e.printStackTrace();
        }
    }

    @SuppressWarnings("unchecked")
    public <T extends RankMongo> T get(String key){
        Optional<RankMongo> optional = dao.findById(key);
        return (T) optional.orElse(null);
    }
}
